<?php
//  Index 模块 公共函数
//  @Hyang 2016年9月23日 星期五
function index_nav($v=null){
    if(!is_object($v)) return false;
    $loginState = '';
    $logined = $v->infoUser('user_nick');
    if($logined){
        $loginState = '
        <li><a href="'.$v->dyUrl('Doeeking','/index.php/Doeeking/Index/Ucenter.html').'" target="_blank">'.$logined.'</a></li>
        <li><a href="'.$v->dyUrl('Doeeking','/index.php/Home/Index/quit.html').'" target="_blank">注销</a></li>';
    }else $loginState = '
        <li><a href="'.$v->dyUrl('Doeeking','/index.php/Home/Index/enter.html?src='.request()->url(true)).'" target="_blank">登录</a></li>
        <li><a href="'.$v->dyUrl('Doeeking','/index.php/Home/Index/login.html').'" target="_blank">注册</a></li>';
    $xhtml = '
        <!-- Fixed navbar -->
        <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="'.$v->dyUrl('Doeeking').'" target="_blank">TeCenter.D</a>
            </div>
            <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
                <li class="index"><a href="/TeCenter/">首页</a></li>
                <li class="about"><a href="/TeCenter/index/about.html">关于</a></li>
                <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
                <ul class="dropdown-menu" role="menu">
                    <li><a href="#">Action</a></li>
                    <li><a href="#">Another action</a></li>
                    <li><a href="#">Something else here</a></li>
                    <li class="divider"></li>
                    <li class="dropdown-header">Nav header</li>
                    <li><a href="#">Separated link</a></li>
                    <li><a href="#">One more separated link</a></li>
                </ul>
                </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                '.$loginState.'
            </ul>
            </div><!--/.nav-collapse -->
        </div>
        </nav>
    ';
    //debugOut($xhtml);
    //$v->assign('index_nav_view',$xhtml);// 无法使用 assign类
    return $xhtml;
}
// 提交表单是生成“正确提示”
function getSuccessTip($opt=null){
    $title = isset($opt['title'])? $opt['title']:'新增一条数据';
    $remark = isset($opt['remark'])? $opt['remark']:'本次数据操作成功';
    return '
        <div style="margin:100px 0 0 100px;max-width:500px;">
            <h1 style="margin:0px;text-align:center;">'.$title.'</h1>
            <div style="color:green;margin:0px;background:silver;padding:20px;">
                <br>时间：'.date('Y-m-d H:m:s').'
                <br>描述：'.$remark.'
            </div>
            <p style="margin:0px;">>> TeCenter@2016-'.date('Y').'</p>
        </div>
    ';
}
// 提交表单是生成“失败提示”
function getFailureTip($opt=null){
    $title = isset($opt['title'])? $opt['title']:'新增一条数据';
    $remark = isset($opt['remark'])? $opt['remark']:'十分遗憾，本次数据操作失败!';
    return '
        <div style="margin:100px 0 0 100px;max-width:500px;">
            <h1 style="margin:0px;text-align:center;">'.$title.'</h1>
            <div style="color:red;margin:0px;background:navajowhite;padding:20px;">
                <br>时间：'.date('Y-m-d H:m:s').'
                <br>描述：'.$remark.'
            </div>
            <p style="margin:0px;">>> TeCenter@2016-'.date('Y').'</p>
        </div>
    ';
}